package model;

import java.sql.Time;
import java.sql.Date;
import java.text.ParseException;
import java.text.SimpleDateFormat;

import utility.dates.*;

/**
 * 
 * @author denilson.dias
 */
public class ModelHoras {
	private Date recordDate;
	private String userName;
	private Date ocurrenceDate;
	private boolean incrementDate;
	private Time entrHour;
	private Time exitBreak;
	private Time entrBreak;
	private Time exitHour;
	private String obs;

	public ModelHoras() {

		userName = System.getProperty("user.name");

	}

	public boolean isIncrementDate() {
		return incrementDate;
	}

	public void setIncrementDate(boolean incrementDate) {

		this.incrementDate = incrementDate;
	}

	public Date getRegistrationDate() {
		return recordDate;
	}
	
	public void setRegistrationDate(String registrationDate) throws Exception {

		this.recordDate = Dates.strToDate(registrationDate);

	}

	public String getUser() {
		return userName;
	}

	public void settUser(String user) {
		this.userName = user;
	}

	public Date getOccurrenceDate() throws Exception {
		return ocurrenceDate;
	}

	public Date getOccurrenceDate(Date prevDate) throws Exception {
		try {

			String newDate;
			newDate = Dates.sumDate((java.sql.Date) prevDate, 1);
			ocurrenceDate = Dates.strToDate(newDate);

		} catch (Exception e) {
			throw new Exception(e.getMessage());
		}

		return ocurrenceDate;
	}

	public void setOccurrenceDate(String ocorrDate) throws Exception {

		this.ocurrenceDate = Dates.strToDate(ocorrDate);
	}

	public Time getEntranceHour() {
		return entrHour;
	}

	public void setEntranceHour(String entranceHour) throws ParseException {
		try {
			SimpleDateFormat formater = new SimpleDateFormat("HH:mm");
			java.util.Date newDate = formater.parse(entranceHour);
			this.entrHour = new Time(newDate.getTime());
		} catch (Exception e) {
			this.entrHour = null;
		}

	}

	public Time getExitBreak() {
		return exitBreak;
	}

	public void setExitBreak(String exitBreak) throws ParseException {
		try {
			SimpleDateFormat formater = new SimpleDateFormat("HH:mm");
			java.util.Date newDate = formater.parse(exitBreak);
			this.exitBreak = new Time(newDate.getTime());
		} catch (Exception e) {
			this.exitBreak = null;
		}
	}

	public Time getEntranceBreak() {
		return entrBreak;
	}

	public void setEntranceBreak(String entranceHour) throws ParseException {
		try {
			SimpleDateFormat formater = new SimpleDateFormat("HH:mm");
			java.util.Date newdate = formater.parse(entranceHour);
			this.entrBreak = new Time(newdate.getTime());
		} catch (Exception e) {
			this.entrBreak = null;
		}
	}

	public Time getExitHour() {
		return exitHour;
	}

	public void setExitHour(String exitHour) throws ParseException {
		try {
			SimpleDateFormat formater = new SimpleDateFormat("HH:mm");
			java.util.Date newDate = formater.parse(exitHour);
			this.exitHour = new Time(newDate.getTime());
		} catch (Exception e) {
			this.exitHour = null;
		}
	}

	public String getObs() {
		return obs;
	}

	public void setObs(String obs) {
		this.obs = obs;
	}


}
